// ----------------------------------------------------------------------------
/**
	File: thetreemovers.cpp
	Author: Zef RosnBrick
	Archive: Live Archive
	Problem Number: 2591
*/
// ----------------------------------------------------------------------------

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

class node
{
	public:
		node(int v) : val(v), left(NULL), right(NULL) {}
		int val;
		node *left, *right;
};

node *add(node *r, int v)
{
	if (r == NULL)
		r = new node(v);
	else if (v < r->val)
		r->left = add(r->left, v);
	else if (v > r->val)
		r->right = add(r->right, v);

	return r;
}

int size(node *b)
{
	if (b != NULL)
		return 1 + size(b->left) + size(b->right);
	else
		return 0;
}

int diff(node *a, node *b)
{
	if (a == NULL && b == NULL)
		return 0;
	else if (a == NULL)
		return size(b);
	else if (b == NULL)
		return 1;
	else if (a->val == b->val)
		return diff(a->left, b->left) + diff(a->right, b->right);
	else
		return 1 + size(b);
}

int main()
{
	int caseno = 0, n, v;
	node *a, *b;

	while (++caseno)
	{
		if (!(cin >> n) || n == -1)
			return 0;

		a = b = NULL;

		for (int i = 0; i < n; i++)
		{
			cin >> v;
			a = add(a, v);
		}

		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> v;
			b = add(b, v);
		}

		int ans = diff(a, b);
		printf("Case %i: %i command%s.\n", caseno, ans, ans != 1 ? "s" : "");
	}
}
